#include <iostream>
#include <string>
using namespace std;

#include <unistd.h>
#include <stdlib.h>     // random()

#include "ThreadPool.h"

class Echo : public CTask
{
public:
    Echo(int s) {m_tag = s;}
    ~Echo() {}
    void run();
private:
    int m_tag;
};

void Echo::run()
{
    usleep(random()%10);
    cout << "I'm task " << m_tag << endl;
}


int main()
{
    CThreadPool *tpool = new CThreadPool();
    tpool->Init(3);

    for (int i = 0; i < 100; i++) {
        CTask *pTask = new Echo(i);
        tpool->AddTask(pTask);
    }

    sleep(1);
    delete tpool;

    return 0;
}